<?php
$url = $mosConfig_live_site."/administrator/components/com_content/uploads/";

$sql = "SELECT * FROM #__content WHERE state=1 AND sectionid=1 AND new=1 ORDER BY ordering ASC, id DESC LIMIT 0,9";
$database->setQuery($sql);
$lsNew = $database->loadObjectList();
?>
<div class="title_main">Sản phẩm mới</div>
<?php
for ($i=0; $i<count($lsNew); $i++){
$link = sefRelToAbs("index.php?option=com_content&task=view&catid=".$lsNew[$i]->catid."&id=".$lsNew[$i]->id).$lsNew[$i]->title_alias.".html";
?>
<div class="boxproduct">
	<div class="image" id="productImageWrapID_<?php echo $lsNew[$i]->id;?>">
		<?php
		if ($lsNew[$i]->img!=''){
		?>
		<a href="<?php echo $link;?>"><img src="<?php echo $url.$lsNew[$i]->img;?>" /></a>
		<?php
		}else{
		?>
		<a href="<?php echo $link;?>"><img src="<?php echo $url;?>no_pic.gif" /></a>
		<?php
		}
		?>
	</div>
	<div class="field"><a href="<?php echo $link;?>"><?php echo $lsNew[$i]->title;?></a></div>
	<div class="price">Giá : <?php echo number_format($lsNew[$i]->price,0,',','.');?> VNĐ</div>
	<div class="field">
		<?php if ($lsNew[$i]->status==1){?>
		<div class="cart">
			<a id="ajax<?php echo $lsNew[$i]->id;?>">
				<img src="<?php echo $mosConfig_live_site;?>/templates/maxco/images/cart.jpg" border="0" id="featuredProduct_<?php echo $lsNew[$i]->id;?>" />
			</a>
		</div>
		<?php }else if ($lsNew[$i]->status==2){?>
		<div class="cart" style="color:#ff7700;">Chưa có hàng</div>
		<?php }else{?>
		<div class="cart" style="color:red;">Hết hàng</div>
		<?php }?>
		<div class="detail"><a href="<?php echo $link;?>">Chi tiết</a></div>
	</div>
</div>
<?php
}
?>
<script type="text/javascript">
$(function() {
	<?php 
	for ($i=0; $i<count($lsNew); $i++){
	?>
	$('#ajax<?php echo $lsNew[$i]->id;?>').click(function() {
		$('#gio_hang').load('<?php echo $mosConfig_live_site;?>/ajax/orderonline.php?id=<?php echo $lsNew[$i]->id;?>');
	});
	<?php }?>
});
</script>
